home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / HPACK78S.ZIP / hpacklib.h < prev    next >
C/C++ Source or Header  |  1992-12-02  |  6KB  |  163 lines

  1. /****************************************************************************
  2. *                                                                            *
  3. *                            HPACK Multi-System Archiver                        *
  4. *                            ===========================                        *
  5. *                                                                            *
  6. *                        HPACK Library Code Interface Header                    *
  7. *                            HPACKLIB.H  Updated 22/03/92                    *
  8. *                                                                            *
  9. * This program is protected by copyright and as such any use or copying of    *
  10. *  this code for your own purposes directly or indirectly is highly uncool    *
  11. *                      and if you do so there will be....trubble.                *
  12. *                 And remember: We know where your kids go to school.            *
  13. *                                                                            *
  14. *        Copyright 1990 - 1992  Peter C.Gutmann.  All rights reserved        *
  15. *                                                                            *
  16. ****************************************************************************/
  17.  
  18. #ifndef _HPACKLIB_DEFINED
  19.  
  20. #define _HPACKLIB_DEFINED
  21.  
  22. #if !defined( __MSDOS__ ) || defined( GUI )
  23.  
  24. /* Macros to turn the generic HPACKLIB functions into their equivalent on
  25.    the current system */
  26.  
  27. #include <stdio.h>                    /* Prototypes for generic functions */
  28. #if defined( __UNIX__ ) && !defined( ULTRIX_OLD )
  29.   #include <malloc.h>                /* Needed for mem.functions on some systems */
  30. #endif /* __UNIX__ && !ULTRIX_OLD */
  31. #if defined( AIX386 ) || defined( __ARC__ ) || defined( __ATARI__ ) || defined( __MSDOS__ )
  32.   #include <stdlib.h>                /* Needed for mem.functions */
  33. #endif /* AIX386 || __ARC__ || __ATARI__ || __MSDOS__ */
  34. #if defined( __ATARI__ )
  35.   #include <conio.h>                /* For console I/O */
  36. #endif /* __ATARI__ */
  37. #if defined( __OS2__ ) && !defined( __GCC__ )
  38.   #include <conio.h>                /* For console I/O */
  39. #endif /* __OS2__ && !__GCC__ */
  40. #include "flags.h"                    /* Flags for stealth-mode check */
  41.  
  42. #ifndef GUI
  43.   #define hprintf        printf        /* Output formatted string/arg-list */
  44.   #ifndef __ARC__
  45.     #define hputchar    putchar        /* Output single char */
  46.   #endif /* __ARC__ */
  47.   #define hputs            puts        /* Output string */
  48.   #define hgets            gets        /* Input string */
  49.  
  50.   #define hprintfs    if( !( flags & STEALTH_MODE ) ) \
  51.                         printf        /* printf() with stealth-mode check */
  52.   #ifndef __ARC__
  53.     #define hputchars    if( !( flags & STEALTH_MODE ) ) \
  54.                             putchar    /* putchar() with stealth-mode check */
  55.   #endif /* __ARC__ */
  56.   #if defined( __AMIGA__ ) || defined( __OS2__ ) || defined( __UNIX__ )
  57.     #define hflush    fflush            /* Overcome buffering on stdout */
  58.   #else
  59.     #define hflush(x)                /* Ba-woooosshhhh!! */
  60.   #endif /* __AMIGA__ || __OS2__ || __UNIX__ */
  61.   #if defined( __AMIGA__ ) || defined( __ARC__ ) || defined( __MAC__ ) || \
  62.       defined( __OS2__ ) || defined( __UNIX__ )
  63.     int hgetch( void );                /* Get char, no echo */
  64.   #else
  65.     #define hgetch    getch            /* Get char, no echo */
  66.   #endif /* __AMIGA__ || __ARC__ || __MAC__ || __UNIX__ */
  67.   #ifdef __ARC__
  68.     void hputchar( const int ch );    /* Output single char */
  69.     #define hputchars    if( !( flags & STEALTH_MODE ) ) \
  70.                             hputchar    /* putchar() with stealth-mode check */
  71.   #endif /* __ARC__ */
  72. #endif /* GUI */
  73.  
  74. #if defined( __OS2__ ) || ( defined( __MSDOS__ ) && defined( GUI ) ) || \
  75.     defined( __MAC__ ) || ( defined( __UNIX__ ) && defined( POSIX ) )
  76.   void *hmalloc( const unsigned long size );    /* Allocate block of memory */
  77.   void *hrealloc( void *buffer, const unsigned long size );    /* Re-allocate block of memory */
  78.   void hfree( void *buffer );        /* Free block of memory */
  79. #else
  80.   #define hmalloc    malloc            /* Allocate block of memory */
  81.   #define hrealloc    realloc            /* Re-allocate block of memory */
  82.   #define hfree        free            /* Free block of memory */
  83. #endif /* __OS2__ */
  84.  
  85. #if defined( __MSDOS__ ) && defined( GUI )
  86.   void *hmallocSeg( const WORD size );    /* Segment-aligned malloc() */
  87. #endif /* __MSDOS__ && GUI */
  88.  
  89. #define sfree(buf,size)        if( flags & CRYPT ) \
  90.                                 memset( buf, 0, size ); \
  91.                             hfree( buf );
  92.                                     /* Safe hfree() which destroys sensitive
  93.                                        data in memory */
  94. #else
  95.  
  96. /* Prototypes for functions in the HPACK libraries */
  97.  
  98. void hprintf( const char *format, ... );
  99. void hprintfs( const char *format, ... );
  100. void hvprintf( void );
  101. void hputchar( const char ch );
  102. void hputchars( const char ch );
  103. void hputs( const char *string );
  104. int hgetch( void );
  105.  
  106. #define hflush(x)                /* No need for hflush() under a real OS */
  107.  
  108. /* The hfree() pseudo-function:  Unlike free(), hfree() is a null function
  109.    since all cases where hmalloc() is called keep the memory allocated until
  110.    HPACK terminates, when a block free is done.  The use of the DYNA memory
  111.    manager does away with the need for a hfree() function.  In addition there
  112.    is no need for an sfree() since this is taken care of by the startup code */
  113.  
  114. #define hfree(ptr)
  115. #define sfree(x,y)
  116.  
  117. /* hmalloc() is called getMem() externally to reduce any confusion that it's
  118.    a malloc() clone */
  119.  
  120. void *getMem( const int size );
  121.  
  122. #define hmalloc(size)    getMem( size )
  123.  
  124. /* hmallocSeg() is a MSDOS-specific hmalloc() which ensure the data is
  125.    segment aligned.  This greatly enhances the simplicity of array indexing
  126.    since a segment register can point at the array base and an index register
  127.    can be used to index into it */
  128.  
  129. void *getMemSeg( const int size );
  130.  
  131. #define hmallocSeg(size)    getMemSeg( size )
  132.  
  133. /* initMem() and endMem() start up and shut down the memory manager */
  134.  
  135. void initMem( void );
  136. void endMem( void );
  137.  
  138. #endif /* !__MSDOS__ */
  139.  
  140. #ifdef GUI
  141.  
  142. /* Prototypes and enumerated types for idiot boxes */
  143.  
  144. typedef enum { ALERT_FILE_IN_ARCH, ALERT_TRUNCATED_PADDING,
  145.                ALERT_DATA_ENCRYPTED, ALERT_DATA_CORRUPTED,
  146.                ALERT_PATH_TOO_LONG, ALERT_CANNOT_PROCESS_ENCR_INFO,
  147.                ALERT_CANNOT_OPEN_DATAFILE, ALERT_CANNOT_OPEN_SCRIPTFILE,
  148.                ALERT_UNKNOWN_ARCH_METHOD, ALERT_NO_OVERWRITE_EXISTING,
  149.                ALERT_FILE_IS_DEVICEDRVR, ALERT_ARCHIVE_UPTODATE,
  150.                ALERT_ERROR_DURING_ERROR_REC, ALERT_UNKNOWN_SCRIPT_COMMAND,
  151.                ALERT_PATH_TOO_LONG_LINE, ALERT_BAD_CHAR_IN_FILENAME_LINE,
  152.                ALERT_CANT_FIND_PUBLIC_KEY, ALERT_SEC_INFO_CORRUPTED,
  153.                ALERT_SECRET_KEY_COMPROMISED, ALERT_ARCH_SECTION_TOO_SHORT,
  154.                ALERT_DIRNAME_CONFLICTS_WITH_FILE, ALERT_PASSWORD_INCORRECT,
  155.                ALERT_FILES_CORRUPTED
  156.              } ALERT_TYPE;
  157.  
  158. void alert( ALERT_TYPE alertType, const char *message );
  159.  
  160. #endif /* GUI */
  161.  
  162. #endif /* !_HPACKLIB_DEFINED */
  163.